<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ServiceController
 *
 * @author nmthong
 */

class AjaxController extends Controller{
    // Members
    /**
     * Key which has to be in HTTP USERNAME and PASSWORD headers 
     */
    Const APPLICATION_ID = 'ASCCPE';
 
    /**
     * Default response format
     * either 'json' or 'xml'
     */
    private $format = 'json';
    /**
     * @return array action filters
     */    

        
        public function actionGetLocation()
        {
            try{
                $group_id = Yii::app()->request->getPost("group_id");
                $connection=Yii::app()->db;   // assuming you have configured a "db" connection
                $query="Select * from ls_users where ls_users.group_id='".$group_id."' and ls_users.admin=0";
                $command=$connection->createCommand($query);
                $dataReader=$command->query();
                $rows_user = array();
                while(($row=$dataReader->read())!==false) {
                    $rows_user[]=$row;
                }   
                $resul=array('data'=>$rows_user,'status'=>'ok');
                $string=json_encode($resul);
                echo $string;                
            }catch(Exception $e){
                $resul=array('data'=>'','status'=>'fail','error'=>$e->getMessage());
                 echo $string=json_encode($resul);
            }
                           

        }      
        
}

?>
